package com.example.controller;

import com.example.entity.BizAssetEntity;
import com.example.respdto.resultDTO;
import com.example.service.BizAssetService;
import com.example.util.PageUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 资产表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-05-30 22:54:41
 */
@RestController
@RequestMapping("generator/bizasset")
public class BizAssetController {
    @Autowired
    private BizAssetService bizAssetService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:bizasset:list")
    public resultDTO list(@RequestParam Map<String, Object> params){
        PageUtils page = bizAssetService.queryPage(params);

        return resultDTO.success(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{pkAsset}")
    @RequiresPermissions("generator:bizasset:info")
    public resultDTO info(@PathVariable("pkAsset") Long pkAsset){
		BizAssetEntity bizAsset = bizAssetService.getById(pkAsset);

        return resultDTO.success(bizAsset);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:bizasset:save")
    public resultDTO save(@RequestBody BizAssetEntity bizAsset){
		bizAssetService.save(bizAsset);

        return resultDTO.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:bizasset:update")
    public resultDTO update(@RequestBody BizAssetEntity bizAsset){
		bizAssetService.updateById(bizAsset);

        return resultDTO.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:bizasset:delete")
    public resultDTO delete(@RequestBody Long[] pkAssets){
		bizAssetService.removeByIds(Arrays.asList(pkAssets));

        return resultDTO.success();
    }

}
